package com.xxzuibang.day16.arrays类;

import java.util.Arrays;
import java.util.List;

public class ArraysMethod2 {
    public static void main(String[] args) {
        //binarySearch二分查找，要求排好序
        Integer[] arr = {1, 2, 90, 123, 567};
        int index = Arrays.binarySearch(arr, 567);
        System.out.println("index=" + index);

        //copyOf数组拷贝
        Integer[] newArr = Arrays.copyOf(arr, arr.length);
        System.out.println("拷贝完成前：");
        System.out.println(Arrays.toString(arr));
        System.out.println("拷贝完成后：");
        System.out.println(Arrays.toString(newArr));

        //fill数组元素的填充
        Integer[] num = new Integer[]{9, 3, 2};
        //使用99填充,可以理解为替换原来的元素
        Arrays.fill(num, 99);
        System.out.println("num数组填充后：");
        System.out.println(Arrays.toString(num));//[99, 99, 99]

        //equals比较两个数组内容是否完全一致,完全一致返回true，不完全一致返回false
        Integer[] arr2 = {1, 2, 90, 123};
        boolean equals = Arrays.equals(arr, arr2);
        System.out.println(equals);//false

        //asList将一组值转为List
        List asList = Arrays.asList(2, 3, 4, 5, 6, 1);
        System.out.println("aList=" + asList);//aList=[2, 3, 4, 5, 6, 1]
        System.out.println("aList的运行类型" + asList.getClass());//aList的运行类型class java.util.Arrays$ArrayList


    }
}